---
import StarlightPage from "@astrojs/starlight/components/StarlightPage.astro";
import { LinkCard } from "@astrojs/starlight/components";
import { getCollection, render } from "astro:content";

export async function getStaticPaths() {
  const changelog = await getCollection("changelog");

  return changelog.map((entry) => ({
    params: {
      version: entry.data.slug,
    },
    props: {
      entry: entry,
    },
  }));
}

const { entry } = Astro.props;
const { Content, headings } = await render(entry);
---

<StarlightPage
  frontmatter={{
    title: entry.data.title,
    description: "List of all changes in this release",
    pagefind: false, // We don't want to pollute our search with release-notes entries
  }}
  headings={headings}
>
  <LinkCard
    title="View on GitHub"
    href={`https://github.com/RIOT-OS/RIOT/releases/tag/${entry.data.slug.replaceAll("-", ".")}`}
    description="The changelog can also be found on GitHub."
  />
  <Content />
</StarlightPage>
